#!/usr/bin/perl -w                                                                                                                                          

use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use FindBin;
use lib "$FindBin::Bin/../../lib/Soozy/lib";
use lib "$FindBin::Bin/../lib";                                                                                                                            

my $help = 0;
my ( $listen, $nproc, $pidfile, $manager, $detach, $keep_stderr );

my $debug        = 0;
my $root         = "$FindBin::Bin/../";
my $mode         = 'dev';
my $max_requests = 0;

GetOptions(
    'debug'          => \$debug,
    'help|?'         => \$help,
    'listen|l=s'     => \$listen,
    'nproc|n=i'      => \$nproc,
    'pidfile|p=s'    => \$pidfile,
    'root=s'         => \$root,
    'mode=s'         => \$mode,
    'manager|M=s'    => \$manager,
    'daemon|d'       => \$detach,
    'keeperr|e'      => \$keep_stderr,
    'max-requests=s' => \$max_requests,
    );

pod2usage(1) if $help;

$ENV{SOOZY_ENGINE} = 'FastCGI';
$ENV{SOOZY_DEBUG} = 1 if $debug;
$ENV{HAAK_ROOT} ||= $root;
$ENV{HAAK_MODE} ||= $mode;

require Haak;

Haak->run(
    $listen,
    {
        nproc        => $nproc,
        pidfile      => $pidfile,
        manager      => $manager,
        detach       => $detach,
	keep_stderr  => $keep_stderr,
        max_requests => $max_requests,
    }
    );

1;

